local matRefraction	= Material( "refract_ring" )


//Initialize function
function EFFECT:Init(data)

	//Default values
	self.Refract = 0
	self.Size = 32

	//Optimisations
	self.Entity:SetRenderBounds(Vector()*-512, Vector()*512)

	//Parent to player
	self.Entity:SetParent(data:GetEntity())

end


//Think function
function EFFECT:Think()

	//Make it bigger and denser
	self.Refract = self.Refract + 2 * FrameTime()
	self.Size = 512 * self.Refract^(0.2)

	//Kill if overdue
	if self.Refract >= 1 then return false end
	return true

end


//Render function
function EFFECT:Render()

	//Update material refraction value
	matRefraction:SetMaterialFloat("$refractamount", math.sin(self.Refract * math.pi) * 0.1)
	render.SetMaterial(matRefraction)
	render.UpdateRefractTexture()

	//Holy fuck what's going on here
	render.DrawSprite((self.Entity:GetPos() + (EyePos()-self.Entity:GetPos()):GetNormal() * EyePos():Distance(self.Entity:GetPos()) * (self.Refract^(0.3)) * 0.8), self.Size, self.Size)

end